package thread;

// 自旋锁
class SpinLock{
    private Thread owner = null;

    public void lock(){
        // 通过 CAS 看锁是否被某个线程持有
        while(!CAS(this.owner, null, Thread.currentThread())){

        }
    }

    public void unlock(){
        this.owner = null;
    }

    private boolean CAS(Thread owner, Thread t1, Thread t2){
        return true;
    }
}

public class ThreadDemo31 {

}
